package view.renderer;

import java.awt.Color;
import java.awt.Graphics;

import data.map.TerrainMap;

public class TerrainRenderer extends Renderer{
	
	public static final int TERRAIN_ID_VOID = 0;
	public static final int TERRAIN_ID_GRASS = 1;
	public static final int TERRAIN_ID_STONE = 2;
	public static final int TERRAIN_ID_DIRT = 3;
	public static final int TERRAIN_ID_WATER = 4;
	public static final int TERRAIN_ID_LAVA = 5;
	public static final int TERRAIN_ID_DARKDIRT = 6;
	
	private int tileSize;
	
	private TerrainMap map;
	
	public TerrainRenderer(TerrainMap map, int tileSize){
		this.map = map;
		this.tileSize = tileSize;
	}
	
	
	public void render(Graphics g){
		for(int i = 0; i < map.getSize(); i++){
			for(int j = 0; j < map.getSize(); j++){
				int type = map.getTerrainAt(i, j);
				g.setColor(getColorForType(type));
				g.fillRect(i*tileSize, j*tileSize, tileSize, tileSize);
			}
		}
	
	}
	
	
	private Color getColorForType(int type){
		switch(type){
		case TERRAIN_ID_VOID: return new Color(0, 0, 0);
		case TERRAIN_ID_GRASS: return new Color(20, 150, 20);
		case TERRAIN_ID_STONE: return new Color(100, 100, 100);
		case TERRAIN_ID_DIRT: return new Color(150, 150, 20);
		case TERRAIN_ID_WATER: return new Color(30, 50, 150);
		case TERRAIN_ID_LAVA: return new Color(150, 20, 20);
		case TERRAIN_ID_DARKDIRT: return new Color(100, 100, 10);
		default: return new Color(0,0,0);
		}
	}

}
